import java.util.concurrent.atomic.AtomicInteger;

public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger atomicInteger = new AtomicInteger();

        Thread thread = new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                atomicInteger.getAndIncrement();
            }
        });

        Thread thread1 = new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                atomicInteger.getAndIncrement();
            }
        });

        thread.start();
        thread1.start();
        thread.join();
        thread1.join();
        System.out.println(atomicInteger);
    }
}
